﻿using System;
using HslCommunication.Algorithms.ConnectPool;

namespace HslCommunication.Enthernet.Redis
{
	/// <summary>
	/// 关于Redis实现的接口<see cref="T:HslCommunication.Algorithms.ConnectPool.IConnector" />，从而实现了数据连接池的操作信息
	/// </summary>
	// Token: 0x02000103 RID: 259
	public class IRedisConnector : IConnector
	{
		/// <inheritdoc cref="P:HslCommunication.Algorithms.ConnectPool.IConnector.IsConnectUsing" />
		// Token: 0x17000501 RID: 1281
		// (get) Token: 0x06001580 RID: 5504 RVA: 0x0006F7D4 File Offset: 0x0006D9D4
		// (set) Token: 0x06001581 RID: 5505 RVA: 0x0006F7DC File Offset: 0x0006D9DC
		public bool IsConnectUsing { get; set; }

		/// <inheritdoc cref="P:HslCommunication.Algorithms.ConnectPool.IConnector.GuidToken" />
		// Token: 0x17000502 RID: 1282
		// (get) Token: 0x06001582 RID: 5506 RVA: 0x0006F7E5 File Offset: 0x0006D9E5
		// (set) Token: 0x06001583 RID: 5507 RVA: 0x0006F7ED File Offset: 0x0006D9ED
		public string GuidToken { get; set; }

		/// <inheritdoc cref="P:HslCommunication.Algorithms.ConnectPool.IConnector.LastUseTime" />
		// Token: 0x17000503 RID: 1283
		// (get) Token: 0x06001584 RID: 5508 RVA: 0x0006F7F6 File Offset: 0x0006D9F6
		// (set) Token: 0x06001585 RID: 5509 RVA: 0x0006F7FE File Offset: 0x0006D9FE
		public DateTime LastUseTime { get; set; }

		/// <summary>
		/// Redis的连接对象
		/// </summary>
		// Token: 0x17000504 RID: 1284
		// (get) Token: 0x06001586 RID: 5510 RVA: 0x0006F807 File Offset: 0x0006DA07
		// (set) Token: 0x06001587 RID: 5511 RVA: 0x0006F80F File Offset: 0x0006DA0F
		public RedisClient Redis { get; set; }

		/// <inheritdoc cref="M:HslCommunication.Algorithms.ConnectPool.IConnector.Close" />
		// Token: 0x06001588 RID: 5512 RVA: 0x0006F818 File Offset: 0x0006DA18
		public void Close()
		{
			RedisClient redis = this.Redis;
			if (redis != null)
			{
				redis.ConnectClose();
			}
		}

		/// <inheritdoc cref="M:HslCommunication.Algorithms.ConnectPool.IConnector.Open" />
		// Token: 0x06001589 RID: 5513 RVA: 0x0006F82D File Offset: 0x0006DA2D
		public void Open()
		{
			RedisClient redis = this.Redis;
			if (redis != null)
			{
				redis.SetPersistentConnection();
			}
		}
	}
}
